package com.tedu.ds.dictOption.service.impl;

import com.tedu.ds.dictOption.mapper.DictOptionMapper;
import com.tedu.ds.dictOption.pojo.dto.DictOptionParam;
import com.tedu.ds.dictOption.pojo.dto.DictOptionQuery;
import com.tedu.ds.dictOption.pojo.entity.DictOption;
import com.tedu.ds.dictOption.pojo.vo.DictOptionVO;
import com.tedu.ds.dictOption.service.DictOptionService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DictOptionServiceImpl implements DictOptionService {
    @Autowired
    private DictOptionMapper dictOptionMapper;

    @Override
    public List<DictOptionVO> select(DictOptionQuery dictOptionQuery) {
        return dictOptionMapper.select(dictOptionQuery);
    }

    @Override
    public void save(DictOptionParam dictOptionParam) {
        DictOption dictOption=new DictOption();
        BeanUtils.copyProperties(dictOptionParam,dictOption);
        if (dictOption.getId()==null){
            dictOptionMapper.insert(dictOption);
        }else {
            dictOptionMapper.update(dictOption);
        }
    }

    @Override
    public void delete(DictOptionParam dictOptionParam) {
        dictOptionMapper.delete(dictOptionParam);
    }
}
